{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "506a48d4",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Skipping line 1513591: expected 23 fields, saw 24\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(19235, 23)"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#导入相关库\n",
    "import warnings\n",
    "warnings.filterwarnings('ignore')\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import time\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "from subprocess import check_output\n",
    "import lightgbm as lgb\n",
    "from tqdm import tqdm_notebook as tqdm\n",
    "from sklearn.preprocessing import MinMaxScaler\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.metrics import confusion_matrix,log_loss\n",
    "from xgboost import XGBClassifier\n",
    "from lightgbm import LGBMClassifier \n",
    "from sklearn.pipeline import Pipeline\n",
    "from sklearn.model_selection import cross_validate\n",
    "%matplotlib inline\n",
    "#读取数据\n",
    "df = pd.read_csv('./第一套题数据/data/Chicago_Crimes.csv',error_bad_lines=False)\n",
    "#随机抽样，抽取1%\n",
    "df_sample = df.sample(frac=0.01)\n",
    "df_sample.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "7ec65c9d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 19235 entries, 985919 to 1078772\n",
      "Data columns (total 23 columns):\n",
      " #   Column                Non-Null Count  Dtype  \n",
      "---  ------                --------------  -----  \n",
      " 0   Unnamed: 0            19235 non-null  int64  \n",
      " 1   ID                    19235 non-null  int64  \n",
      " 2   Case Number           19235 non-null  object \n",
      " 3   Date                  19235 non-null  object \n",
      " 4   Block                 19235 non-null  object \n",
      " 5   IUCR                  19235 non-null  object \n",
      " 6   Primary Type          19235 non-null  object \n",
      " 7   Description           19235 non-null  object \n",
      " 8   Location Description  19235 non-null  object \n",
      " 9   Arrest                19235 non-null  bool   \n",
      " 10  Domestic              19235 non-null  bool   \n",
      " 11  Beat                  19235 non-null  int64  \n",
      " 12  District              19235 non-null  float64\n",
      " 13  Ward                  12269 non-null  float64\n",
      " 14  Community Area        12269 non-null  float64\n",
      " 15  FBI Code              19235 non-null  object \n",
      " 16  X Coordinate          18919 non-null  float64\n",
      " 17  Y Coordinate          18919 non-null  object \n",
      " 18  Year                  19235 non-null  float64\n",
      " 19  Updated On            19235 non-null  object \n",
      " 20  Latitude              18919 non-null  object \n",
      " 21  Longitude             18919 non-null  float64\n",
      " 22  Location              18919 non-null  object \n",
      "dtypes: bool(2), float64(6), int64(3), object(12)\n",
      "memory usage: 3.3+ MB\n"
     ]
    }
   ],
   "source": [
    "df_sample.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "18512bd1",
   "metadata": {},
   "outputs": [],
   "source": [
    "#其中 IUCR,FBI Code,Case Number,IDI它们是一种主要类型本身的编码，会给我们一个不切实际的效果很好的预测，用del直接删除掉\n",
    "del df_sample['IUCR']\n",
    "del df_sample['Case Number']\n",
    "del df_sample['ID']\n",
    "del df_sample['FBI Code']\n",
    "del df_sample['Updated On']\n",
    "del df_sample['Arrest']\n",
    "del df_sample['Domestic']\n",
    "del df_sample['Unnamed: 0']\n",
    "del df_sample['Latitude']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "60e09178",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 19235 entries, 985919 to 1078772\n",
      "Data columns (total 14 columns):\n",
      " #   Column                Non-Null Count  Dtype  \n",
      "---  ------                --------------  -----  \n",
      " 0   Date                  19235 non-null  object \n",
      " 1   Block                 19235 non-null  object \n",
      " 2   Primary Type          19235 non-null  object \n",
      " 3   Description           19235 non-null  object \n",
      " 4   Location Description  19235 non-null  object \n",
      " 5   Beat                  19235 non-null  int64  \n",
      " 6   District              19235 non-null  float64\n",
      " 7   Ward                  12269 non-null  float64\n",
      " 8   Community Area        12269 non-null  float64\n",
      " 9   X Coordinate          18919 non-null  float64\n",
      " 10  Y Coordinate          18919 non-null  object \n",
      " 11  Year                  19235 non-null  float64\n",
      " 12  Longitude             18919 non-null  float64\n",
      " 13  Location              18919 non-null  object \n",
      "dtypes: float64(6), int64(1), object(7)\n",
      "memory usage: 2.2+ MB\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Date                    0\n",
       "Block                   0\n",
       "Primary Type            0\n",
       "Description             0\n",
       "Location Description    0\n",
       "Beat                    0\n",
       "District                0\n",
       "Ward                    0\n",
       "Community Area          0\n",
       "X Coordinate            0\n",
       "Y Coordinate            0\n",
       "Year                    0\n",
       "Longitude               0\n",
       "Location                0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#使用describe函数查看数值类型数据和标量数据的基本信息，包括最小值、最大值、均值、四分位数、总数等，查看数据的缺失值数量和占比情况\n",
    "df_sample.info()\n",
    "df_sample.isnull().sum()\n",
    "df_sample.describe(include='O')\n",
    "df_na = pd.DataFrame(data=df_sample.isnull().sum()/df.shape[0],columns=['miss_rate']).sort_values(by='miss_rate',ascending=False)\n",
    "df_sample.dropna(inplace=True)\n",
    "df_sample.isnull().sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9069d1ab",
   "metadata": {},
   "source": [
    "1.先将字段Date转为datetime类型，再扩展字段，提取年、月、周、日、小时信息。同时删除Date字段"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a85b489d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 由考生填写\n",
    "df_sample['Date'] = df_sample['Date'].astype(np.datetime64)\n",
    "df_sample['year'] = df_sample['Date'].dt.year\n",
    "df_sample['month'] = df_sample['Date'].dt.month\n",
    "df_sample['week'] = df_sample['Date'].dt.weekday\n",
    "df_sample['day'] = df_sample['Date'].dt.day\n",
    "df_sample['hour'] = df_sample['Date'].dt.hour\n",
    "\n",
    "#删除Date列\n",
    "del df_sample['Date']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2d3688e0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Block</th>\n",
       "      <th>Primary Type</th>\n",
       "      <th>Description</th>\n",
       "      <th>Location Description</th>\n",
       "      <th>Beat</th>\n",
       "      <th>District</th>\n",
       "      <th>Ward</th>\n",
       "      <th>Community Area</th>\n",
       "      <th>X Coordinate</th>\n",
       "      <th>Y Coordinate</th>\n",
       "      <th>Year</th>\n",
       "      <th>Longitude</th>\n",
       "      <th>Location</th>\n",
       "      <th>year</th>\n",
       "      <th>month</th>\n",
       "      <th>week</th>\n",
       "      <th>day</th>\n",
       "      <th>hour</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>985919</th>\n",
       "      <td>017XX E 79TH ST</td>\n",
       "      <td>NARCOTICS</td>\n",
       "      <td>POSS: CRACK</td>\n",
       "      <td>STREET</td>\n",
       "      <td>414</td>\n",
       "      <td>4.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>43.0</td>\n",
       "      <td>1189127.0</td>\n",
       "      <td>1852941.0</td>\n",
       "      <td>2003.0</td>\n",
       "      <td>-87.582506</td>\n",
       "      <td>(41.751526005, -87.582506478)</td>\n",
       "      <td>2003</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>12</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1307371</th>\n",
       "      <td>065XX N CAMPBELL AVE</td>\n",
       "      <td>BATTERY</td>\n",
       "      <td>DOMESTIC BATTERY SIMPLE</td>\n",
       "      <td>RESIDENCE</td>\n",
       "      <td>2412</td>\n",
       "      <td>24.0</td>\n",
       "      <td>50.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1158465.0</td>\n",
       "      <td>1943369.0</td>\n",
       "      <td>2003.0</td>\n",
       "      <td>-87.692394</td>\n",
       "      <td>(42.000348471, -87.692393691)</td>\n",
       "      <td>2003</td>\n",
       "      <td>9</td>\n",
       "      <td>5</td>\n",
       "      <td>20</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1629435</th>\n",
       "      <td>082XX S KIMBARK AVE</td>\n",
       "      <td>THEFT</td>\n",
       "      <td>$500 AND UNDER</td>\n",
       "      <td>SIDEWALK</td>\n",
       "      <td>411</td>\n",
       "      <td>4.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>45.0</td>\n",
       "      <td>1186306.0</td>\n",
       "      <td>1850713.0</td>\n",
       "      <td>2004.0</td>\n",
       "      <td>-87.592914</td>\n",
       "      <td>(41.745479241, -87.592914211)</td>\n",
       "      <td>2004</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>22</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>920750</th>\n",
       "      <td>006XX N KEDZIE AVE</td>\n",
       "      <td>BATTERY</td>\n",
       "      <td>SIMPLE</td>\n",
       "      <td>STREET</td>\n",
       "      <td>1121</td>\n",
       "      <td>11.0</td>\n",
       "      <td>27.0</td>\n",
       "      <td>23.0</td>\n",
       "      <td>1154929.0</td>\n",
       "      <td>1903987.0</td>\n",
       "      <td>2002.0</td>\n",
       "      <td>-87.706462</td>\n",
       "      <td>(41.892353434, -87.706461515)</td>\n",
       "      <td>2002</td>\n",
       "      <td>11</td>\n",
       "      <td>1</td>\n",
       "      <td>19</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1289338</th>\n",
       "      <td>057XX S HOYNE AVE</td>\n",
       "      <td>BATTERY</td>\n",
       "      <td>AGG PO HANDS NO/MIN INJURY</td>\n",
       "      <td>STREET</td>\n",
       "      <td>715</td>\n",
       "      <td>7.0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>67.0</td>\n",
       "      <td>1163342.0</td>\n",
       "      <td>1866605.0</td>\n",
       "      <td>2003.0</td>\n",
       "      <td>-87.676614</td>\n",
       "      <td>(41.789600527, -87.676613798)</td>\n",
       "      <td>2003</td>\n",
       "      <td>9</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        Block Primary Type                 Description  \\\n",
       "985919        017XX E 79TH ST    NARCOTICS                 POSS: CRACK   \n",
       "1307371  065XX N CAMPBELL AVE      BATTERY     DOMESTIC BATTERY SIMPLE   \n",
       "1629435   082XX S KIMBARK AVE        THEFT              $500 AND UNDER   \n",
       "920750     006XX N KEDZIE AVE      BATTERY                      SIMPLE   \n",
       "1289338     057XX S HOYNE AVE      BATTERY  AGG PO HANDS NO/MIN INJURY   \n",
       "\n",
       "        Location Description  Beat  District  Ward  Community Area  \\\n",
       "985919                STREET   414       4.0   8.0            43.0   \n",
       "1307371            RESIDENCE  2412      24.0  50.0             2.0   \n",
       "1629435             SIDEWALK   411       4.0   8.0            45.0   \n",
       "920750                STREET  1121      11.0  27.0            23.0   \n",
       "1289338               STREET   715       7.0  15.0            67.0   \n",
       "\n",
       "         X Coordinate Y Coordinate    Year  Longitude  \\\n",
       "985919      1189127.0    1852941.0  2003.0 -87.582506   \n",
       "1307371     1158465.0    1943369.0  2003.0 -87.692394   \n",
       "1629435     1186306.0    1850713.0  2004.0 -87.592914   \n",
       "920750      1154929.0    1903987.0  2002.0 -87.706462   \n",
       "1289338     1163342.0    1866605.0  2003.0 -87.676614   \n",
       "\n",
       "                              Location  year  month  week  day  hour  \n",
       "985919   (41.751526005, -87.582506478)  2003      1     6   12     3  \n",
       "1307371  (42.000348471, -87.692393691)  2003      9     5   20    19  \n",
       "1629435  (41.745479241, -87.592914211)  2004      5     5   22    15  \n",
       "920750   (41.892353434, -87.706461515)  2002     11     1   19    16  \n",
       "1289338  (41.789600527, -87.676613798)  2003      9     6    7    20  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_sample.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "117a0e60",
   "metadata": {},
   "source": [
    "2.字符串类型字段'Block','Primary Type','Description','Location Description','Location',在进行数据分析之前需要数值化，提高运行效率。factorize\n",
    "函数可以将字符串类型数据映射为一组数字，相同的字符串类型映射为想通的数字。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "29eaab46",
   "metadata": {},
   "outputs": [],
   "source": [
    "#由考生填写\n",
    "list_col = ['Block','Description','Location Description','Location']\n",
    "for col in list_col:\n",
    "    df_sample[col]= pd.factorize(df_sample[col])[0]\n",
    "#如果考题中要求把'Primary Type列名改成'Primary_Type,那么可以拿出来单独处理\n",
    "df_sample['Primary_Type'] = pd.factorize(df_sample['Primary Type'])[0]\n",
    "del df_sample['Primary Type']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "54850a79",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数值类型数据处理\n",
    "# 采用MinMaxScaler对数据进行规范化\n",
    "from sklearn.preprocessing import MinMaxScaler\n",
    "df_sample['X Coordinate'] = df_sample['X Coordinate'].astype(float)\n",
    "df_sample['Y Coordinate'] = df_sample['Y Coordinate'].astype(float)\n",
    "df_sample['X Coordinate'] = MinMaxScaler().fit_transform(df_sample['X Coordinate'].values.reshape(-1,1))\n",
    "df_sample['Y Coordinate'] = MinMaxScaler().fit_transform(df_sample['Y Coordinate'].values.reshape(-1,1))\n",
    "\n",
    "from sklearn.model_selection import train_test_split\n",
    "X_train, X_test, y_train, y_test = train_test_split(df_sample.loc[:,df_sample.columns!='Primary_Type'], df_sample['Primary_Type'], test_size=0.3, random_state=42)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b2775e74",
   "metadata": {},
   "source": [
    "3.使用GradientBoostingClassifier分类器进行训练模型model_gbdt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "6be18e3e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "f1_score为0.8074380165289257\n"
     ]
    }
   ],
   "source": [
    "from sklearn.ensemble import GradientBoostingClassifier\n",
    "from sklearn.metrics import f1_score\n",
    "#由考生填写\n",
    "model_gbdt = GradientBoostingClassifier(n_estimators=8)  #设置参数， 如果题目没指定就用默认的，不用填\n",
    "model_gbdt.fit(X=X_train,y=y_train)\n",
    "y_prel = model_gbdt.predict(X_test)\n",
    "f1_score1 = f1_score(y_test,y_prel,average='micro')\n",
    "print('f1_score为{}'.format(f1_score1))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f6a23fd5",
   "metadata": {},
   "source": [
    "4.使用网格搜索交叉验证对模型model_gbdt进行优化，调整参数learn_rate建议值为[0.1,0.2,0.3,0.4,0.5],cv采用5折进行模型训练，得到最优模型、最优参数和最优评分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "f7c9edca",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>#sk-container-id-1 {color: black;background-color: white;}#sk-container-id-1 pre{padding: 0;}#sk-container-id-1 div.sk-toggleable {background-color: white;}#sk-container-id-1 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-1 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-1 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-1 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-1 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-1 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-1 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-1 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-1 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-1 div.sk-item {position: relative;z-index: 1;}#sk-container-id-1 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-1 div.sk-item::before, #sk-container-id-1 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-1 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-1 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-1 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-1 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-1 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-1 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-1 div.sk-label-container {text-align: center;}#sk-container-id-1 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-1 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>GridSearchCV(cv=5, estimator=GradientBoostingClassifier(n_estimators=8),\n",
       "             param_grid={&#x27;learning_rate&#x27;: [0.1, 0.2, 0.3, 0.4, 0.5]},\n",
       "             scoring=make_scorer(f1_score))</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item sk-dashed-wrapped\"><div class=\"sk-label-container\"><div class=\"sk-label sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" ><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">GridSearchCV</label><div class=\"sk-toggleable__content\"><pre>GridSearchCV(cv=5, estimator=GradientBoostingClassifier(n_estimators=8),\n",
       "             param_grid={&#x27;learning_rate&#x27;: [0.1, 0.2, 0.3, 0.4, 0.5]},\n",
       "             scoring=make_scorer(f1_score))</pre></div></div></div><div class=\"sk-parallel\"><div class=\"sk-parallel-item\"><div class=\"sk-item\"><div class=\"sk-label-container\"><div class=\"sk-label sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-2\" type=\"checkbox\" ><label for=\"sk-estimator-id-2\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">estimator: GradientBoostingClassifier</label><div class=\"sk-toggleable__content\"><pre>GradientBoostingClassifier(n_estimators=8)</pre></div></div></div><div class=\"sk-serial\"><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-3\" type=\"checkbox\" ><label for=\"sk-estimator-id-3\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">GradientBoostingClassifier</label><div class=\"sk-toggleable__content\"><pre>GradientBoostingClassifier(n_estimators=8)</pre></div></div></div></div></div></div></div></div></div></div>"
      ],
      "text/plain": [
       "GridSearchCV(cv=5, estimator=GradientBoostingClassifier(n_estimators=8),\n",
       "             param_grid={'learning_rate': [0.1, 0.2, 0.3, 0.4, 0.5]},\n",
       "             scoring=make_scorer(f1_score))"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#由考生填写\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "from sklearn.metrics import make_scorer\n",
    "\n",
    "param_grids = {'learning_rate':[0.1,0.2,0.3,0.4,0.5]}\n",
    "model_gs = GridSearchCV(estimator=model_gbdt,param_grid=param_grids,cv=5,scoring=make_scorer(f1_score))\n",
    "model_gs.fit(X=X_train,y=y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "71b84c5f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "nan"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 最优模型\n",
    "model_gs.best_estimator_\n",
    "# #最优参数\n",
    "model_gs.best_params_\n",
    "# # 最优评分\n",
    "model_gs.best_score_"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bba37916",
   "metadata": {},
   "source": [
    "5.使用VotingClassifier聚合了多个基础模型的预测结果。通过硬投票，软投票和自定义权重的软投票三种方式进行比较，确定最后的结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "aca6c3b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>#sk-container-id-2 {color: black;background-color: white;}#sk-container-id-2 pre{padding: 0;}#sk-container-id-2 div.sk-toggleable {background-color: white;}#sk-container-id-2 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-2 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-2 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-2 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-2 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-2 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-2 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-2 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-2 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-2 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-2 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-2 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-2 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-2 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-2 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-2 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-2 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-2 div.sk-item {position: relative;z-index: 1;}#sk-container-id-2 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-2 div.sk-item::before, #sk-container-id-2 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-2 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-2 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-2 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-2 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-2 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-2 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-2 div.sk-label-container {text-align: center;}#sk-container-id-2 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-2 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-2\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>VotingClassifier(estimators=[(&#x27;xgb&#x27;,\n",
       "                              XGBClassifier(base_score=None, booster=None,\n",
       "                                            callbacks=None,\n",
       "                                            colsample_bylevel=None,\n",
       "                                            colsample_bynode=None,\n",
       "                                            colsample_bytree=0.6, device=None,\n",
       "                                            early_stopping_rounds=None,\n",
       "                                            enable_categorical=False,\n",
       "                                            eval_metric=None,\n",
       "                                            feature_types=None, gamma=None,\n",
       "                                            grow_policy=None,\n",
       "                                            importance_type=None,\n",
       "                                            interaction_constraints=None,\n",
       "                                            learning_rat...\n",
       "                                            max_delta_step=None, max_depth=3,\n",
       "                                            max_leaves=None, min_child_weight=2,\n",
       "                                            missing=nan,\n",
       "                                            monotone_constraints=None,\n",
       "                                            multi_strategy=None,\n",
       "                                            n_estimators=150, n_jobs=None,\n",
       "                                            num_parallel_tree=None,\n",
       "                                            random_state=None, ...)),\n",
       "                             (&#x27;rf&#x27;,\n",
       "                              RandomForestClassifier(max_depth=1,\n",
       "                                                     min_samples_leaf=63,\n",
       "                                                     min_samples_split=4,\n",
       "                                                     n_estimators=50,\n",
       "                                                     oob_score=True)),\n",
       "                             (&#x27;svc&#x27;, SVC(C=0.1, probability=True))])</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item sk-dashed-wrapped\"><div class=\"sk-label-container\"><div class=\"sk-label sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-4\" type=\"checkbox\" ><label for=\"sk-estimator-id-4\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">VotingClassifier</label><div class=\"sk-toggleable__content\"><pre>VotingClassifier(estimators=[(&#x27;xgb&#x27;,\n",
       "                              XGBClassifier(base_score=None, booster=None,\n",
       "                                            callbacks=None,\n",
       "                                            colsample_bylevel=None,\n",
       "                                            colsample_bynode=None,\n",
       "                                            colsample_bytree=0.6, device=None,\n",
       "                                            early_stopping_rounds=None,\n",
       "                                            enable_categorical=False,\n",
       "                                            eval_metric=None,\n",
       "                                            feature_types=None, gamma=None,\n",
       "                                            grow_policy=None,\n",
       "                                            importance_type=None,\n",
       "                                            interaction_constraints=None,\n",
       "                                            learning_rat...\n",
       "                                            max_delta_step=None, max_depth=3,\n",
       "                                            max_leaves=None, min_child_weight=2,\n",
       "                                            missing=nan,\n",
       "                                            monotone_constraints=None,\n",
       "                                            multi_strategy=None,\n",
       "                                            n_estimators=150, n_jobs=None,\n",
       "                                            num_parallel_tree=None,\n",
       "                                            random_state=None, ...)),\n",
       "                             (&#x27;rf&#x27;,\n",
       "                              RandomForestClassifier(max_depth=1,\n",
       "                                                     min_samples_leaf=63,\n",
       "                                                     min_samples_split=4,\n",
       "                                                     n_estimators=50,\n",
       "                                                     oob_score=True)),\n",
       "                             (&#x27;svc&#x27;, SVC(C=0.1, probability=True))])</pre></div></div></div><div class=\"sk-parallel\"><div class=\"sk-parallel-item\"><div class=\"sk-item\"><div class=\"sk-label-container\"><div class=\"sk-label sk-toggleable\"><label>xgb</label></div></div><div class=\"sk-serial\"><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-5\" type=\"checkbox\" ><label for=\"sk-estimator-id-5\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">XGBClassifier</label><div class=\"sk-toggleable__content\"><pre>XGBClassifier(base_score=None, booster=None, callbacks=None,\n",
       "              colsample_bylevel=None, colsample_bynode=None,\n",
       "              colsample_bytree=0.6, device=None, early_stopping_rounds=None,\n",
       "              enable_categorical=False, eval_metric=None, feature_types=None,\n",
       "              gamma=None, grow_policy=None, importance_type=None,\n",
       "              interaction_constraints=None, learning_rate=0.1, max_bin=None,\n",
       "              max_cat_threshold=None, max_cat_to_onehot=None,\n",
       "              max_delta_step=None, max_depth=3, max_leaves=None,\n",
       "              min_child_weight=2, missing=nan, monotone_constraints=None,\n",
       "              multi_strategy=None, n_estimators=150, n_jobs=None,\n",
       "              num_parallel_tree=None, random_state=None, ...)</pre></div></div></div></div></div></div><div class=\"sk-parallel-item\"><div class=\"sk-item\"><div class=\"sk-label-container\"><div class=\"sk-label sk-toggleable\"><label>rf</label></div></div><div class=\"sk-serial\"><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-6\" type=\"checkbox\" ><label for=\"sk-estimator-id-6\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">RandomForestClassifier</label><div class=\"sk-toggleable__content\"><pre>RandomForestClassifier(max_depth=1, min_samples_leaf=63, min_samples_split=4,\n",
       "                       n_estimators=50, oob_score=True)</pre></div></div></div></div></div></div><div class=\"sk-parallel-item\"><div class=\"sk-item\"><div class=\"sk-label-container\"><div class=\"sk-label sk-toggleable\"><label>svc</label></div></div><div class=\"sk-serial\"><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-7\" type=\"checkbox\" ><label for=\"sk-estimator-id-7\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">SVC</label><div class=\"sk-toggleable__content\"><pre>SVC(C=0.1, probability=True)</pre></div></div></div></div></div></div></div></div></div></div>"
      ],
      "text/plain": [
       "VotingClassifier(estimators=[('xgb',\n",
       "                              XGBClassifier(base_score=None, booster=None,\n",
       "                                            callbacks=None,\n",
       "                                            colsample_bylevel=None,\n",
       "                                            colsample_bynode=None,\n",
       "                                            colsample_bytree=0.6, device=None,\n",
       "                                            early_stopping_rounds=None,\n",
       "                                            enable_categorical=False,\n",
       "                                            eval_metric=None,\n",
       "                                            feature_types=None, gamma=None,\n",
       "                                            grow_policy=None,\n",
       "                                            importance_type=None,\n",
       "                                            interaction_constraints=None,\n",
       "                                            learning_rat...\n",
       "                                            max_delta_step=None, max_depth=3,\n",
       "                                            max_leaves=None, min_child_weight=2,\n",
       "                                            missing=nan,\n",
       "                                            monotone_constraints=None,\n",
       "                                            multi_strategy=None,\n",
       "                                            n_estimators=150, n_jobs=None,\n",
       "                                            num_parallel_tree=None,\n",
       "                                            random_state=None, ...)),\n",
       "                             ('rf',\n",
       "                              RandomForestClassifier(max_depth=1,\n",
       "                                                     min_samples_leaf=63,\n",
       "                                                     min_samples_split=4,\n",
       "                                                     n_estimators=50,\n",
       "                                                     oob_score=True)),\n",
       "                             ('svc', SVC(C=0.1, probability=True))])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 由考生填写\n",
    "from sklearn.model_selection import cross_val_score\n",
    "from sklearn.linear_model import LogisticRegression\n",
    "from sklearn.tree import DecisionTreeClassifier\n",
    "from sklearn.svm import SVC\n",
    "from sklearn.ensemble import VotingClassifier\n",
    "from sklearn.ensemble import AdaBoostClassifier\n",
    "from xgboost import XGBClassifier\n",
    "from sklearn.ensemble import RandomForestClassifier\n",
    "import warnings\n",
    "warnings.filterwarnings('ignore')\n",
    "\n",
    "clf1 = XGBClassifier(learning_rate=0.1,n_estimators=150,max_depth=3,min_child_weight=2,subsample=0.7,colsample_bytree=0.6,objective='binary:logistic')\n",
    "clf2 = RandomForestClassifier(n_estimators=50,max_depth=1,min_samples_split=4,min_samples_leaf=63,oob_score=True)\n",
    "clf3 = SVC(C=0.1,probability=True)  #软投票的时候,probability必须指定且为True\n",
    "\n",
    "clf = VotingClassifier(estimators=[('xgb',clf1),('rf',clf2),('svc',clf3)],voting='hard')\n",
    "clf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "2999367a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 8470 entries, 1033772 to 1624693\n",
      "Data columns (total 17 columns):\n",
      " #   Column                Non-Null Count  Dtype  \n",
      "---  ------                --------------  -----  \n",
      " 0   Block                 8470 non-null   int64  \n",
      " 1   Description           8470 non-null   int64  \n",
      " 2   Location Description  8470 non-null   int64  \n",
      " 3   Beat                  8470 non-null   int64  \n",
      " 4   District              8470 non-null   float64\n",
      " 5   Ward                  8470 non-null   float64\n",
      " 6   Community Area        8470 non-null   float64\n",
      " 7   X Coordinate          8470 non-null   float64\n",
      " 8   Y Coordinate          8470 non-null   float64\n",
      " 9   Year                  8470 non-null   float64\n",
      " 10  Longitude             8470 non-null   float64\n",
      " 11  Location              8470 non-null   int64  \n",
      " 12  year                  8470 non-null   int64  \n",
      " 13  month                 8470 non-null   int64  \n",
      " 14  week                  8470 non-null   int64  \n",
      " 15  day                   8470 non-null   int64  \n",
      " 16  hour                  8470 non-null   int64  \n",
      "dtypes: float64(7), int64(10)\n",
      "memory usage: 1.2 MB\n",
      "Accuracy:0.90(+/- 0.01) [XGBBoosting]\n",
      "Accuracy:0.29(+/- 0.01) [Random Forest]\n",
      "Accuracy:0.21(+/- 0.00) [SVM]\n",
      "Accuracy:0.38(+/- 0.01) [Voting]\n"
     ]
    }
   ],
   "source": [
    "#硬投票\n",
    "eclf = VotingClassifier(estimators=[('xgb',clf1),('rf',clf2),('svc',clf3)],voting='hard')\n",
    "X_train.info()\n",
    "index = 0\n",
    "for clf,label in zip([clf1,clf2,clf3,eclf],['XGBBoosting','Random Forest','SVM','Voting']):\n",
    "        scores = cross_val_score(clf,X_train,y_train,cv=5,scoring='accuracy')\n",
    "        print(\"Accuracy:%0.2f(+/- %0.2f) [%s]\"%(scores.mean(),scores.std(),label))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "21bc3cf0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 8470 entries, 1033772 to 1624693\n",
      "Data columns (total 17 columns):\n",
      " #   Column                Non-Null Count  Dtype  \n",
      "---  ------                --------------  -----  \n",
      " 0   Block                 8470 non-null   int64  \n",
      " 1   Description           8470 non-null   int64  \n",
      " 2   Location Description  8470 non-null   int64  \n",
      " 3   Beat                  8470 non-null   int64  \n",
      " 4   District              8470 non-null   float64\n",
      " 5   Ward                  8470 non-null   float64\n",
      " 6   Community Area        8470 non-null   float64\n",
      " 7   X Coordinate          8470 non-null   float64\n",
      " 8   Y Coordinate          8470 non-null   float64\n",
      " 9   Year                  8470 non-null   float64\n",
      " 10  Longitude             8470 non-null   float64\n",
      " 11  Location              8470 non-null   int64  \n",
      " 12  year                  8470 non-null   int64  \n",
      " 13  month                 8470 non-null   int64  \n",
      " 14  week                  8470 non-null   int64  \n",
      " 15  day                   8470 non-null   int64  \n",
      " 16  hour                  8470 non-null   int64  \n",
      "dtypes: float64(7), int64(10)\n",
      "memory usage: 1.2 MB\n",
      "Accuracy:0.90(+/- 0.01) [XGBBoosting]\n",
      "Accuracy:0.29(+/- 0.00) [Random Forest]\n",
      "Accuracy:0.21(+/- 0.00) [SVM]\n",
      "Accuracy:0.88(+/- 0.01) [Voting]\n"
     ]
    }
   ],
   "source": [
    "#软投票只需要设置voting='soft'即可\n",
    "eclf = VotingClassifier(estimators=[('xgb',clf1),('rf',clf2),('svc',clf3)],voting='soft')\n",
    "X_train.info()\n",
    "for clf,label in zip([clf1,clf2,clf3,eclf],['XGBBoosting','Random Forest','SVM','Voting']):\n",
    "    scores = cross_val_score(clf,X_train,y_train,cv=5,scoring='accuracy')\n",
    "    print(\"Accuracy:%0.2f(+/- %0.2f) [%s]\" %(scores.mean(),scores.std(),label))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "97535283",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 8470 entries, 1033772 to 1624693\n",
      "Data columns (total 17 columns):\n",
      " #   Column                Non-Null Count  Dtype  \n",
      "---  ------                --------------  -----  \n",
      " 0   Block                 8470 non-null   int64  \n",
      " 1   Description           8470 non-null   int64  \n",
      " 2   Location Description  8470 non-null   int64  \n",
      " 3   Beat                  8470 non-null   int64  \n",
      " 4   District              8470 non-null   float64\n",
      " 5   Ward                  8470 non-null   float64\n",
      " 6   Community Area        8470 non-null   float64\n",
      " 7   X Coordinate          8470 non-null   float64\n",
      " 8   Y Coordinate          8470 non-null   float64\n",
      " 9   Year                  8470 non-null   float64\n",
      " 10  Longitude             8470 non-null   float64\n",
      " 11  Location              8470 non-null   int64  \n",
      " 12  year                  8470 non-null   int64  \n",
      " 13  month                 8470 non-null   int64  \n",
      " 14  week                  8470 non-null   int64  \n",
      " 15  day                   8470 non-null   int64  \n",
      " 16  hour                  8470 non-null   int64  \n",
      "dtypes: float64(7), int64(10)\n",
      "memory usage: 1.2 MB\n",
      "Accuracy:0.90(+/- 0.01) [XGBBoosting]\n",
      "Accuracy:0.29(+/- 0.00) [Random Forest]\n",
      "Accuracy:0.21(+/- 0.00) [SVM]\n",
      "Accuracy:0.24(+/- 0.01) [Voting]\n"
     ]
    }
   ],
   "source": [
    "#软投票自定义权重\n",
    "eclf = VotingClassifier(estimators=[('xgb',clf1),('rf',clf2),('svc',clf3)],voting='soft',weights=[0,1,9])\n",
    "X_train.info()\n",
    "for clf,label in zip([clf1,clf2,clf3,eclf],['XGBBoosting','Random Forest','SVM','Voting']):\n",
    "    scores = cross_val_score(clf,X_train,y_train,cv=5,scoring='accuracy')\n",
    "    print(\"Accuracy:%0.2f(+/- %0.2f) [%s]\" %(scores.mean(),scores.std(),label))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6d3acce8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8378fe01",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c69c223a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
